/** 
 * PredefinedFuntionExpression.java
 * @author Lex
 * 2007-8-26 ����12:16:56
 */
package fun.symtable.system;

import fun.parser.ast.node.base.Expression;
import fun.symtable.SymbolTable;
import fun.symtable.VariableEntry;

public abstract class UnaryFuntion extends Expression implements Function {
	public static final String ARGUMENT_NAME = "x";
	public static final String[] ARGUMENTS = { ARGUMENT_NAME };
	// =============================================
	private String functionName = null;

	public UnaryFuntion(String functionName) {
		super();
		this.functionName = functionName;
	}

	public String getFunctionName() {
		return this.functionName;
	}

	public String[] getArguments() {
		return ARGUMENTS;
	}

	public Expression getExpression() {
		return this;
	}

	protected double getArgumentValue(SymbolTable symtable) {
		VariableEntry var = symtable.getVariable(ARGUMENT_NAME);
		return var.getValue();
	}

	public String toString() {
		StringBuilder b = new StringBuilder();
		// b.append( functionName ).append( '(' );
		// b.append( ARGUMENT_NAME ).append( ") = " );
		b.append(functionName).append('(');
		b.append(ARGUMENT_NAME).append(')');
		return b.toString();
	}
}
